package de.baumann.browser.activitys.duobao

import android.content.Context
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v4.view.ViewPager
import android.widget.RadioGroup
import de.baumann.browser.R
import de.baumann.browser.adapter.PagerAdapter
import de.baumann.browser.adapter.PagerAdapter2
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.fragments.duobao.DuoBaoHomeFragment
import de.baumann.browser.fragments.duobao.DuoBaoJieXiaoFragment
import de.baumann.browser.fragments.duobao.DuoBaoWoFragment
import de.baumann.browser.iview.IBaseView
import kotlinx.android.synthetic.main.activity_duo_bao_main.*

class DuoBaoMainActivity : BaseOdinActivity<IBaseView, BasePresenter<IBaseView>>() {

    companion object {
        fun startDuoBaoMainActivity(context: Context) {
            context.startActivity(Intent(context, DuoBaoMainActivity::class.java))
        }
    }

    override fun getLayout(): Int {
        return R.layout.activity_duo_bao_main
    }

    override fun initView() {
        val fragments = arrayListOf(DuoBaoHomeFragment.instance,
                DuoBaoJieXiaoFragment.instance,
                DuoBaoWoFragment.instance)
        val adapter = PagerAdapter(supportFragmentManager, fragments, null)
        dobaomaiViewPager.adapter = adapter
        dobaomaiViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {
            }

            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
            }

            override fun onPageSelected(position: Int) {
                when (position) {
                    0 -> rbHome.isChecked = true
                    1 -> rbJieXiao.isChecked = true
                    2 -> rbWo.isChecked = true
                }
            }
        })

        bottom_navgation.setOnCheckedChangeListener { _, p1 ->
            when (p1) {
                R.id.rbHome -> dobaomaiViewPager.currentItem = 0
                R.id.rbJieXiao -> dobaomaiViewPager.currentItem = 1
                R.id.rbWo -> dobaomaiViewPager.currentItem = 2
            }
        }
    }

    override fun initData() {
    }

    override fun createPresenter(): BasePresenter<IBaseView>? {
        return null
    }

    override fun createView(): IBaseView? {
        return null
    }
}